Ext.onReady(function(){ 

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'under';

var modelStore=new Ext.data.Store({ 
	proxy:new Ext.data.HttpProxy({
	url:'showPDModelListRetail.do',
	method:'GET'
	}), 
	reader:new Ext.data.JsonReader({ },[
	{name:'name'}, 
	{name:'code'}
	]) ,
	autoLoad: true
});


//客户基本信息
var addForm = new Ext.form.FormPanel({ 
id: 'addForm', 
title: '最新评级信息', 
renderTo:"list",
height: 200, 
//样式 
bodyStyle: 'margin:5px;text-align:left;padding:5px 60px;', 
frame: true, 
xtype: 'filedset', 
labelWidth: 100, 
items: 
[ { xtype: 'fieldset', 
collapsible: true, 
autoHeight: true, 
autoWidth: true, 
items: 
[
	{layout:"column",
		items:[{
			columnWidth : .5, // 该列有整行中所占百分比
		           layout : "form",
		           items : [{
		        	   xtype: 'textfield', 
		       		id:'custId',
		       		name: 'custId', 
		       		fieldLabel: '客户编号', 
		       		readOnly:true,
		       		hidden:true,
		       		width: 250
		}
		]}
]},	
	
{layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'combo',
        	   id : "modelId",
               store :modelStore,
               fieldLabel: '打分卡模板',
               valueField : 'code',
               displayField : 'name',
               emptyText : '请选择打分卡模板...',
               editable: false,
               typeAhead : true,
               width: 250,
               mode:'remote',  
               triggerAction : 'all',
               selectOnFocus : true,
               hiddenName:'modelId'
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
xtype: 'textfield', 
	id:'confirmPdvalue',
	name: 'confirmPdvalue', 
	fieldLabel: '评分得分', 
	width: 250
}
]}
]},



{
layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'datefield',
      			id: 'confirmDate', 
      			name: 'confirmDate', 
      			fieldLabel: '评分时间',
      			allowBlank: true,
      			editable:false,  
      			format : 'Y-m-d' ,
      			width: 250 
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'textfield', 
	       		id:'confirmUserId',
	       		name: 'confirmUserId', 
	       		fieldLabel: '经办人', 
	       		width: 250
}
]} 
]},
	

] 
}],
buttonAlign:'right',
buttons: 
[  
{ text: '下一步', handler: editFunctionAndNext } ,
{ text: '保存', handler: editFunction } 
] 
});


//表单加载数据
addForm.form.load({  
    waitMsg : '正在加载数据请稍后',
    waitTitle : '提示',
    url : 'customer/getIndNewestPD.do', 
    method:'post',
    success:function(form,action){
    	
    },  
    failure:function(form,action){
     Ext.Msg.alert('提示','数据加载失败');  
    }  
});

function editFunction(){

	if(addForm.form.isValid()){
		addForm.form.doAction('submit', { 
			url : 'customer/editIndNewestPD.do', 
			method : 'post', 
			success : function() {
				Ext.Msg.alert('提示', '保存成功！'); 
			}, 
			failure : function() { 
				Ext.Msg.alert('提示', '保存失败！'); 
			} 
		}); 
	}
	
}

function editFunctionAndNext(){
	if(addForm.form.isValid()){
		addForm.form.doAction('submit', { 
			url : 'customer/editIndNewestPD.do', 
			method : 'post', 
			success : function() {
				Ext.Msg.confirm("Confirm",'保存成功，是否继续添加历史评级信息',function(bool){
					if(bool=='yes'){
						window.location.href = "view/customer/Customer_IndHistoryPD.jsp";
						return true;
					}
					else{
						return false;	
					}
				}); 
				//alert("成功");
				
			}, 
			failure : function() { 
				Ext.Msg.alert('提示', '保存失败！'); 
			} 
		}); 
	}
}
       
}); 